import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
import settings from './modules/settings'
import permission from './modules/permission'
import user from './modules/user'

Vue.use(Vuex)

const store = new Vuex.Store({
  state:{
    accept:'.pdf,.docx,.pptx,.ppt,.xlsx,.png,.jpeg,.jpg,.xls,.doc,.txt',
    catchList: '',//固定要缓存组件
  },
  mutations:{
    // 对指定组件进行动态更改缓存（缓存）--组件调用该方法时，判断该组件是否存在于该缓存数组，无则添加
    isKeepAlive(state, component) {
      state.catchList = component;
    },
    // 对指定组件进行动态更改缓存（不缓存）--组件调用该方法时，从缓存数组中删除对应的组件元素
    noKeepAlive(state, component) {
        let index = state.catchList.indexOf(component);
        index > -1 && state.catchList.splice(index, 1);
    },
  },
  modules: {
    app,
    permission,
    settings,
    user
  },
  getters
})

export default store
